import sqlite3
import platform

if platform.platform().startswith('Windows'):
    data_file = '../db.sqlite3'
    sql_file = 'init.sql'
else:
    sql_file = '/backend/sql/init.sql'
    data_file = '/backend/db.sqlite3'

# con = sqlite3.connect('../../db.sqlite3')
con = sqlite3.connect(data_file)
cur = con.cursor()
with open(sql_file, 'r', encoding='utf-8') as f:
    lines = f.readlines()
for i in lines:
    i = i.strip()
    if i:
        try:
            cur.execute(i)
            con.commit()
            print(i)
        except Exception as e:
            print(repr(e))
con.close()
